package com.atguigu.tingshu.common.config.redis;

import com.google.common.hash.BloomFilter;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: BloomFilterConfig
 * Package: com.atguigu.tingshu.common.config.redis
 * Description:布隆过滤器的配置
 */
@Configuration
public class BloomFilterConfig {
    @Autowired
    private RedissonClient redissonClient;

    /**
     * 初始化布隆过滤器
     * @return
     */
    @Bean
    public RBloomFilter rBloomFilter(){
        RBloomFilter<Object> rBloomFilter = redissonClient.getBloomFilter("albumInfo");
        rBloomFilter.tryInit(100000,0.01);
        return rBloomFilter;
    }
}
